import java.util.Scanner;

/**
 * Creat by TanLei
 * Description:
 * User:86183
 * Date:2022-05-11
 * Time:21:42
 */
public class Demo17 {

    private static Object locker1 = new Object();
    private static Object locker2 = new Object();

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(()->{
            Scanner scanner = new Scanner(System.in);
            while (true){
                synchronized (locker1){
                    System.out.println("请输入一个整数：");
                    int a = scanner.nextInt();
                    System.out.println("a:"+a);
                }
            }
        });
        t1.start();

        Thread.sleep(1000);

        Thread t2 = new Thread(()->{
            synchronized (locker2){
                System.out.println("hello t2");
            }
        });
        t2.start();
    }
}
